package com.sdyeda.readiot.data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SetDataServiceImpl implements SetDataService {

	@Autowired 
	SetDataRepository setRepository;
	
	@Override
	public Map<String, SetData> getAllSetData() {
		Map<String,SetData> ret = new HashMap<String,SetData>();
		List<SetData> sets = setRepository.findAll();
		sets.forEach(set->{
			ret.put(set.getName(), set);
		});
		return ret;
	}

	@Override
	public SetData findSetDataByName(String name) {
		return setRepository.findOneByName(name);
	}

	@Override
	public void save(SetData set) {
		setRepository.save(set);
	}

}
